package com.daycomtech.jgooglechart.test;


import java.io.IOException;
import java.util.ArrayList;

import com.daycomtech.jgooglechart.charts.JGPieChart;
import com.daycomtech.jgooglechart.dataobjects.JGChartColor;
import com.daycomtech.jgooglechart.dataobjects.JGChartData;
import com.daycomtech.jgooglechart.exception.JGoogleChartException;

public class DemoPieChart
{
	/**
	 * @param args
	 */
	public static void main(String[] args)
	{
		JGPieChart chart = new JGPieChart(150,JGPieChart.PieChart3D );

		ArrayList<JGChartData> chart_datas = new ArrayList<JGChartData>();


		float[] data = new float[] { 0.20f, 0.20f, 0.30f, 0.30f };
		String[] labels = new String[] { "Spain", "France", "Italy", "Canada" };

		for (int i = 0; i < data.length; i++)
		{
			JGChartData chart_data = new JGChartData();

			chart_data.setValue(data[i]);
			chart_data.setLabel(labels[i]);
			chart_data.setColor(JGChartColor.palette[i]);

			chart_datas.add(chart_data);
		}

		chart.setChartDatas(chart_datas);

		try
		{
			//Get URL String,
			String urlString = chart.getUrlString();

			System.out.println("URL STRING:"+urlString);

			//Save to File!!!
			chart.saveToFile("C://pepe.jpg", "jpg");
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}
		catch (JGoogleChartException e)
		{
			e.printStackTrace();
		}


	}

}
